package com.jk.admin.controller;

import com.jk.admin.entity.Product;
import com.jk.admin.service.EchartsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
public class EchartsController {

    @Autowired
    private EchartsService echartsService;
    @RequestMapping("cha")
    public List<Product> cha(){
        return echartsService.cha();
    }
    @RequestMapping("cha1")
    public List cha1(){
        List<Product> cha = echartsService.cha();
        List<Map> list = new ArrayList<Map>();
        for (int i = 0; i < cha.size(); i++) {
            Map map=new HashMap<>();
            map.put("value", cha.get(i).getProduct_num());
            map.put("name", cha.get(i).getProduct_name());
            System.out.println(map);
            list.add(i, map);
            System.out.println(list);
        }

        return list;
    }
}
